#!/bin/bash
rm -f /home/deck/.cache/installsteampp/Linux.sh
wget -P /home/deck/.cache/installsteampp https://steampp.net/Install/Linux.sh
chmod +x /home/deck/.cache/installsteampp/Linux.sh
konsole --new-tab -e "bash /home/deck/.cache/installsteampp/Linux.sh"
rm -f /home/deck/.local/share/applications/Watt\ Toolkit.desktop
rm -f /home/deck/Desktop/Watt\ Toolkit.desktop
echo "[Desktop Entry]
Categories=Utility;Application;
Exec=/home/deck/.cache/installsteampp/run_steampp.sh
Icon=/home/deck/.cache/installsteampp/Watt-Toolkit.png
Name=Watt Toolkit
StartupNotify=false
Terminal=false
Type=Application
Version=3" > /home/deck/.local/share/applications/Watt\ Toolkit.desktop
chmod +x /home/deck/.local/share/applications/Watt\ Toolkit.desktop
cp '/home/deck/.local/share/applications/Watt Toolkit.desktop' /home/deck/Desktop/
DESKTOP_FILE="/home/deck/Desktop/SteamOS万能工具箱.desktop"
EXEC_LINE=$(grep "^Exec=" "$DESKTOP_FILE")
if [[ $EXEC_LINE =~ echo\ \"([^\"]+)\" ]]; then
    C_PASSWORD="${BASH_REMATCH[1]}"
    echo "自动读取到终端密码: $C_PASSWORD"

    echo "$C_PASSWORD" | sudo -S trust anchor --store SteamTools.Certificate.cer
else
    echo "获取密码失败，请在终端手动执行以下命令手动导入证书：
cd /home/deck/.local/share/Steam++/Plugins/Accelerator && sudo trust anchor --store SteamTools.Certificate.cer" > /home/deck/.cache/installsteampp/手动导入证书.txt
    kate /home/deck/.cache/installsteampp/手动导入证书.txt
fi

